
(define R (make-routine (lambda (input yield)
			  (inform "A -" input)
			  (inform "B -" (yield 1))
			  (inform "C -" (yield 2))
			  (inform "D -" (yield 3))
			  (inform "E -" 'e))))

(list
 (routine-next R 'a)
 (routine-next R 'b)
 (routine-next R 'c))

(routine-reset R)

;; => (1 2 3) 
;; =| A: a
;;    B: b
;;    C: c

(define R (make-routine (lambda (input yield)
			  (for-each (lambda (n)
				      (let ((i (random '(1/2 1 3/2 2))))
					(inform "R -" n i)
					(inform "T -" (yield i))))
				    (iota 10)))))

(tschedule-at 
 (current-tschedule)
 (lambda (pulse time)
   (let ((v (random '(a b c))))
     (inform "S -" v pulse time)
     (routine-next R v))))

(routine-reset R)

(routine-next R #f)
